﻿using JetBrains.Annotations;

namespace MugenMvvmToolkit.Interfaces
{
    /// <summary>
    ///     Represents the interface that provides methods to manage entity state.
    /// </summary>
    public interface IEntityStateProvider
    {
        /// <summary>
        ///     Gets a value indicating whether the provider supports changed detection.
        /// </summary>
        bool IsSupportChangeDetection { get; }

        /// <summary>
        ///     Saves a state of entity.
        /// </summary>
        /// <param name="entity">The specified entity.</param>
        /// <returns>An instance of object.</returns>
        object Save([NotNull]object entity);

        /// <summary>
        ///     Applies a state of entity.
        /// </summary>
        /// <param name="entity">The specified entity.</param>
        /// <returns>An instance of object.</returns>
        object Apply([NotNull]object entity);

        /// <summary>
        ///     Cancels a state of entity.
        /// </summary>
        /// <param name="entity">The specified entity.</param>
        /// <returns>An instance of object.</returns>
        object Cancel([NotNull]object entity);

        /// <summary>
        ///     Gets a value indicating whether the entity has changes.
        /// </summary>
        [Pure]
        bool HasChanges([NotNull]object entity, [NotNull] string propertyName);

        /// <summary>
        ///     Gets a value indicating whether the entity has changes.
        /// </summary>
        [Pure]
        bool HasChanges([NotNull]object entity);
    }
}